package com.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LogFilter implements Filter {

	public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
			throws IOException, ServletException {
		HttpServletRequest request=(HttpServletRequest)req;
		HttpServletResponse response = (HttpServletResponse)resp;
		System.out.println("---请求的内容---" +request.getRequestURI());
		
		java.util.Date date = new java.util.Date(); 
		response.setDateHeader("Expires",date.getTime()+60000); //Expires:过时期限值 
		response.setHeader("Cache-Control", "public");          //Cache-Control来控制页面的缓存与否,public:浏览器和缓存服务器都可以缓存页面信息；
		response.setHeader("Pragma", "Pragma");                 //Pragma:设置页面是否缓存，为Pragma则缓存，no-cache则不缓存
		/*
		response.setHeader( "Pragma", "no-cache" ); 
		response.setDateHeader("Expires", 0); 
		response.addHeader( "Cache-Control", "no-cache" );//浏览器和缓存服务器都不应该缓存页面信息
		 */
		chain.doFilter(request, response);
	}

}
